from odoo import api, fields, models, tools, _


class ProductTemplate(models.Model):
    _inherit = "product.template"
    _description = "Product Template Inherit"
    _order = "sequence asc, id desc"

    item_ids = fields.One2many(
        'product.pricelist.item', 'product_tmpl_id', 'Pricelist Items',
        copy=True)


class ProductPricelist(models.Model):
    _inherit = "product.pricelist"
    _description = "Product Pricelist Inherit"
    _order = "sequence asc, id desc"

    # @api.model
    # def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
    #     res = super(ProductPricelist, self).fields_view_get(view_id, view_type, toolbar=toolbar, submenu=False)
    #     if view_type != 'form':
    #         return res
    #
    #     if not (self._context.get('active_model') and self._context.get('active_id')):
    #         return res
    #
    #     if not self.get_module_list():
    #         res['arch'] = '''<form string="Products Price List">
    #                             <sheet>
    #                                 <div class="oe_title">
    #                                     <h1><field name="name" placeholder="e.g. USD Retailers"/></h1>
    #                                 </div>
    #                                 <group>
    #                                     <field name="currency_id" groups="base.group_multi_currency"/>
    #                                 </group>
    #                             </sheet>
    #                         </form>'''
    #
    #     return res